import request from '@/utils/request.js'
import { commentURL } from '@/utils/config'
// 获取商品的详细数据
export const findGoods = id => {
  return request({
    method: 'get',
    url: '/goods',
    data: { id }
  })
}
export const findRelGoods = (id, limit = 16) => {
  return request({
    method: 'get',
    url: '/goods/relevant',
    data: { id, limit }
  })
}
export const findHotGoods = ({ id, type, limit = 3 }) => {
  return request({
    method: 'get',
    url: '/goods/hot',
    data: { id, type, limit }
  })
}
// 获取商品的评论的统计数据
export const findCommentInfoByGoods = id => {
  // return request({method: 'get',url: '`/goods/${id}/evaluate`'})
  return request({
    method: 'get',
    // 当请求地址是http或者是https等标准协议时，那么axios基准路径不会再次拼接
    // 评论数据没有正式的接口，如下的地址是模拟的假数据
    url: `${commentURL}goods/${id}/evaluate`
  })
}

// https://mock.boxuegu.com/mock/1175/goods/${id}/evaluate
export const findCommentListByGoods = (id, data) => {
  return request({
    method: 'get',
    url: `${commentURL}goods/${id}/evaluate/page`,
    data
  })
}
